using System;
using WindowsLive;
using WindowsLive.Writer;
using WindowsLive.Writer.Api;

namespace SmilingGoat.WindowsLiveWriter.Flickr
{
    [InsertableContentSource("Flickr Image"), WriterPlugin("67d89376-1fb8-4939-a374-81ce8a6ebbaa", "Flickr Image Reference", "Images.FFWTrans.png", PublisherUrl = "http://www.flickr4writer.com", Description = "Plugin for retrieving Flickr images")]
    public class FlickrContentSource : ContentSource
    {
        #region WLW Overrides
        public override System.Windows.Forms.DialogResult CreateContent(System.Windows.Forms.IWin32Window dialogOwner, ref string newContent)
        {
            using (InsertFlickrImageForm flickr = new InsertFlickrImageForm(new FlickrContext(base.Options)))
            {
                System.Windows.Forms.DialogResult formResult = flickr.ShowDialog(dialogOwner);

                FlickrContext context = new FlickrContext(base.Options);
                context.FlickrUserId = flickr.FlickrUserId.Trim();
                context.FlickrUserName = flickr.FlickrUserName.Trim();

                if (formResult == System.Windows.Forms.DialogResult.OK)
                {
                    newContent = FlickrPluginHelper.GenerateFlickrHtml(flickr.SelectedPhoto, flickr.ImageSourceUrl, flickr.CssClass, flickr.BorderThickness, flickr.VerticalPadding, flickr.HorizontalPadding, flickr.Alignment, flickr.EnableHyperLink);
                }
                return formResult;
            }
        }
        #endregion
    }
}
